跳到主要内容

监控RabbitMQ

最后 更新

RabbitMQ当前提供两种方式接入监控数据

方法一:使用内置Prometheus Plugin(推荐)

版本要求: RabbitMQ (version >= 3.8.0)

步骤如下:

  1. 在已经启动的RabbitMQ服务运行环境中,通过下列命令开启Prometheus插件
rabbitmq-plugins enable rabbitmq_prometheus
  1. 将以下配置添加到configmap/apo-grafana-alloy-config中,替换其中YOUR_RABBITMQ_SERVER_IP变量
prometheus.scrape "rabbitmq" {
targets = [
{
__address__ = "YOUR_RABBITMQ_SERVER_IP:15692",
job = "integrations/rabbitmq",
},
]
scheme = "http"
scrape_interval = "60s"
forward_to = [prometheus.relabel.example.receiver]
}

注意 YOUR_RABBITMQ_SERVER_IP 替换时不加http或https前缀 , 如 192.168.1.1:15692

  1. 使用APO Grafana内携带的RabbitMQ 官方指标面板查看监控数据

方法二:使用社区开源Exporter(已集成进Alloy内)

版本要求: RabbitMQ (version >= 3.6.8), 更早的版本也可以支持,参考配置修改说明

步骤如下:

  1. 将以下配置添加到 configmap/apo-grafana-alloy-config中, 下面是最基础的配置,替换其中YOUR_RABBITMQ_URL变量
prometheus.exporter.rabbitmq "rabbitmq_demo" {
rabbit_url = YOUR_RABBITMQ_URL
}

prometheus.scrape "rabbitmq_demo" {
targets = prometheus.exporter.rabbitmq.rabbitmq_demo.targets
forward_to = [prometheus.relabel.example.receiver]
}
  1. 使用APO Grafana内携带的 RabbitMQ 指标(kbudde/rabbitmq_exporter) 面板查看监控数据

配置说明:

prometheus.exporter.rabbitmq块内可选配置如下,配置项均来自kbudde/rabbitmq_exporter

Environment variabledefaultdescription
rabbit_urlhttp://127.0.0.1:15672url to rabbitMQ management plugin (must start with http(s)://)
rabbit_userguestusername for rabbitMQ management plugin. User needs monitoring tag!
rabbit_passwordguestpassword for rabbitMQ management plugin
rabbit_connectiondirectdirect or loadbalancer, strips the self label when loadbalancer
rabbit_user_filelocation of file with username (useful for docker secrets)
rabbit_password_filelocation of file with password (useful for docker secrets)
publish_port9419Listening port for the exporter
publish_addr""Listening host/IP for the exporter
output_formatTTYLog ouput format. TTY and JSON are suported
log_levelinfolog level. possible values: "debug", "info", "warning", "error", "fatal", or "panic"
cafileca.pempath to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist
certfileclient-cert.pempath to client certificate used to verify the exporter's authenticity. Will be ignored if the file does not exist
keyfileclient-key.pempath to private key used with certificate to verify the exporter's authenticity. Will be ignored if the file does not exist
skipverifyfalsetrue/0 will ignore certificate errors of the management plugin
skip_vhost^$regex, matching vhost names are not exported. First performs INCLUDE_VHOST, then SKIP_VHOST. Applies to queues and exchanges
include_vhost.*regex vhost filter. Only matching vhosts are exported. Applies to queues and exchanges
include_queues.*regex queue filter. Just matching names are exported
skip_queues^$regex, matching queue names are not exported (useful for short-lived rpc queues). First performed INCLUDE, after SKIP
include_exchanges.*regex exchange filter. (Only exchanges in matching vhosts are exported)
skip_exchanges^$regex, matching exchanges names are not exported. First performed INCLUDE, after SKIP
rabbit_capabilitiesbert,no_sortcomma-separated list of extended scraping capabilities supported by the target RabbitMQ server
rabbit_exportersexchange,node,queueList of enabled modules. Possible modules: connections,shovel,federation,exchange,node,queue,memory
rabbit_timeout30timeout in seconds for retrieving data from management plugin.
max_queues0max number of queues before we drop metrics (disabled if set to 0)
exclude_metricsMetric names to exclude from export. comma-seperated. e.g. "recv_oct, recv_cnt". See exporter_*.go for names